$(function () {
    //热门请求
    var hotmax = document.getElementsByClassName('hotmax')[0]
    $.ajax({
        url: 'http://localhost:3000/play/hot',
        type: 'get',
        success: function (data) {
            //得到的总数据
            data.forEach(function (item, val) {
                // 里面的每一个数组
                console.log(item[val]);
                var hotimg = document.createElement('div')
                hotimg.className = 'hotimg'
                hotmax.append(hotimg)
                var img = document.createElement('img')
                img.className = 'hotimgs'
                hotimg.append(img)
                img.src = item[val].img
                var p = document.createElement('p')
                p.innerText = item[val].text
                hotimg.append(p)
                var span1 = document.createElement('span')
                var span2 = document.createElement('span')
                span1.innerText = 2032
                span2.innerText = "20台"
                hotimg.append(span1)
                hotimg.append(span2)
                var p2 = document.createElement('p')
                var span3 = document.createElement('span')
                span3.innerText = 1392
                p2.innerText = '申请'
                p2.appendChild(span3)
                hotimg.appendChild(p2)
                var p3 = document.createElement('p')
                p3.innerText = '剩余时间2天'
                hotimg.appendChild(p3)
            });
        }
    })

    //报告精选请求
    var reportimg = document.getElementsByClassName('reportimg')[0]
    $.ajax({
        url: 'http://localhost:3000/report/new',
        type: "get",
        success: function (data) {
            console.log(data);
            var str = ''
            for (var i in data) {
                str += '<div class="reportimgmax">' + '<img src=" ' + data[i].img + '" >' + '<p>' + data[i].text + '</p> ' + '<div class="ping">' + '<p>' + data[i].uName + '</p>' + '<p><img src="../img/zan.png" >3 <img src="../img/xin.png" >3' + '</p > ' + ' </div > ' + '</div > '
                reportimg.innerHTML = str


            }
        }
    })
    var kuwanimg = document.getElementsByClassName('kuwanimg')[0]
    $.ajax({
        url: 'http://localhost:3000/report/hot',
        type: 'get',
        success: function (data) {
            console.log(data);
            var str = ''
            for (var i in data) {
                str += '<div class="reportimgmax">' + '<img src=" ' + data[i].img + '" >' + '<p>' + data[i].text + '</p> ' + '<div class="ping">' + '<p>' + data[i].uName + '</p>' + '<p><img src="../img/zan.png" >3 <img src="../img/xin.png" >3' + '</p > ' + ' </div > ' + '</div > '
                kuwanimg.innerHTML = str
            }
        }
    })
})